<?php spl_autoload_register('X_autoload');
function X_autoload($class){
    if(substr($class,0,2)=='X_'){
        $class= strtolower($class);
        $autoload[]= LIBS_PATH.'/helpers/'.substr($class,2).'.php';
        $autoload[]= LIBS_PATH.'/modules/'.substr($class,2).'.php';
        $autoload[]= LIBS_PATH.'/plugins/'.substr($class,2).'.php';
    }else if(substr($class,-10)=='Controller'){
        $autoload[]= APPLICATION_PATH.'/controllers/'.substr($class,0,-10).'Controller.php';
        //$autoload[]= APPLICATION_PATH.'/controllers/'.strtolower(substr($class,0,-10)).'Controller.php';
    }else if(substr($class,-5)=='Model'){
        $autoload[]= APPLICATION_PATH.'/models/'.substr($class,0,-5).'Model.php';
        //$autoload[]= APPLICATION_PATH.'/models/'.strtolower(substr($class,0,-5)).'Model.php';
    }else{
        $class= strtolower($class);
        $autoload[]= APPLICATION_PATH.'/'.$class.'.php';
        $autoload[]= APPLICATION_PATH.'/helpers/'.$class.'.php';
        $autoload[]= APPLICATION_PATH.'/modules/'.$class.'.php';
        $autoload[]= APPLICATION_PATH.'/plugins/'.$class.'.php';
    }
    ob_start();
    foreach($autoload as $a)if(is_file($a)&&(include $a))break;
    X_ob::addOutput($class,ob_get_clean());
}